<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" http-equiv="Content-Type" content="application/msword"/>
    <title th:text="${swaggerInfo.title == null ? '' : swaggerInfo.title}">Title</title>
    <style type="text/css">
        body {
            font-family: Trebuchet MS, sans-serif;
            font-size: 15px;
            width: 80%;
            margin: auto;
        }

        .text-center {
            text-align: center;
        }

        .back-color {
            background-color: #FFACAC
        }

        .title {
            font-weight: bold;
        }

        table {
            border-collapse: collapse;
            width: 100%;
            word-wrap: break-word;
            word-break: break-all;
        }

        table, th, td {
            border: 1px solid black;
        }
    </style>
    <script type="text/javascript">
      alert('balabala');
    </script>
</head>
<body>
<h1 class="text-center"
    th:text="${swaggerInfo.title}">
    系统名称</h1>
<h3 class="text-center" th:text="|${swaggerInfo.description}${#bools.isTrue(swaggerInfo.version) ? '-' +  swaggerInfo.version : ''}|">文档描述-版本号</h3>
<div th:each="tag : ${swaggerInfo.tagList}">
    <h2 th:text="|${tagStat.count}. ${tag.name}|">1. Tag名称</h2>
    <p style="text-indent: 2em" th:text="${tag.description}">这是Tag的一段描述文本</p>
    <div style="margin: 0 2em" th:each="path : ${tag.pathList}">
        <table>
            <tr>
                <td class="back-color title" colspan="7" th:text="|${pathStat.count}. ${path.summary?: ''}|">1. 接口名称</td>
            </tr>
            <tr>
                <td class="text-center" width="10%">描述</td>
                <td colspan="6" th:text="${path.description}">获取用户信息</td>
            </tr>
            <tr>
                <td class="text-center" width="10%">URL</td>
                <td colspan="6" th:text="${path.path}">/user/{username}</td>
            </tr>
            <tr>
                <td class="text-center" width="10%">方法</td>
                <td colspan="6" th:text="${#strings.toLowerCase(path.method)}">GET</td>
            </tr>
            <tr>
                <td class="text-center" rowspan="3"
                    th:rowspan="${(path.params == null ? 1 : #lists.size(path.params)) + 1}"
                    width="10%">请求
                </td>
                <th width="10%" class="back-color">参数名</th>
                <th width="10%" class="back-color">数据类型</th>
                <th width="15%" class="back-color">引用对象</th>
                <th width="10%" class="back-color">传递方式</th>
                <th width="10%" class="back-color">是否必填</th>
                <th class="back-color">说明</th>
            </tr>
            <tr th:each="param : ${path.params}" class="text-center">
                <td width="10%" th:text="${param.name?: ''}">username</td>
                <td width="10%" th:text="${param.dataType == null ? '' : #strings.toLowerCase(param.dataType)}">STRING</td>
                <td width="15%"
                    th:text="${param.schema != null ? param.schema.refName : ''}"></td>
                <td width="15%" th:text="${param.paramType?: ''}">path</td>
                <td width="15%" th:text="${param.required ? '是' : '否'}">是</td>
                <td th:text="${param.description}">用户名称</td>
            </tr>
            <tr th:if="${path.params == null}" class="text-center">
                <td>/</td>
                <td>/</td>
                <td>/</td>
                <td>/</td>
                <td>/</td>
                <td>/</td>
            </tr>
            <tr>
                <td class="text-center" rowspan="2"
                    th:rowspan="${(path.responses == null ? 1 : #lists.size(path.responses)) + 1}"
                    width="10%">响应
                </td>
                <th width="20%" class="back-color">状态码</th>
                <th width="15%" class="back-color">数据类型</th>
                <th width="15%" class="back-color">引用对象</th>
                <th colspan="4" class="back-color">说明</th>
            </tr>
            <tr th:if="${path.responses == null}" class="text-center">
                <td>/</td>
                <td>/</td>
                <td>/</td>
                <td>/</td>
                <td>/</td>
                <td>/</td>
            </tr>
            <tr th:unless="${path.responses == null}" th:each="response : ${path.responses}" class="text-center">
                <td width="10%" th:text="${response.status ?: ''}">200</td>
                <td width="15%" th:text="${response.dataType == null ? '' : #strings.toLowerCase(response.dataType)}">STRING</td>
                <td width="15%" th:text="${response.refName}">
                    test
                </td>
                <td colspan="4" th:text="${response.description}">成功</td>
            </tr>
        </table>
        <br/>
    </div>
</div>
<h2>Models</h2>
<div style="margin: 0 2em" th:each="model : ${swaggerInfo.models}">
    <table>
        <tr>
            <td class="back-color title" colspan="5" th:text="${model.title == null ? '' : model.title}">User</td>
        </tr>
        <tr>
            <td class="text-center" width="20%">描述</td>
            <td colspan="4" th:text="${model.description}">用户实体</td>
        </tr>
        <tr>
            <td class="text-center" rowspan="2" th:rowspan="${#lists.size(model.properties) + 1}" width="10%">属性</td>
            <th width="10%" class="back-color">名称</th>
            <th width="10%" class="back-color">类型</th>
            <th width="15%" class="back-color">引用对象</th>
            <th class="back-color">说明</th>
        </tr>
        <tr th:each="prop : ${model.properties}">
            <td width="10%" class="text-center" th:text="${prop.name}">username</td>
            <td width="10%" class="text-center" th:text="${#strings.toLowerCase(prop.type)}">STRING</td>

            <td width="10%" class="text-center">
                <span th:text="${#strings.equalsIgnoreCase(prop.type, 'REF') ? prop.ref : ''}">string</span>
                <span th:text="${#strings.equalsIgnoreCase(prop.type, 'OBJECT') ? prop.title : ''}">string</span>
                <span th:text="${#strings.equalsIgnoreCase(prop.type, 'ARRAY') ? prop.refName : ''}">string</span>
            </td>
            <td class="text-center" th:text="${prop.description}">用户姓名</td>
        </tr>
        <tr>
            <td class="text-center" width="20%">示例</td>
            <td colspan="4" th:text="${model.jsonExample}">{"username" : ""zhangsan"}</td>
        </tr>
    </table>
    <br/>
</div>
</body>
</html>
